# import random
# def guess_number_game():
#     target_number = random.randint(1, 100)
#     attempts = 0
#     max_attempts = 7
#     while True:
#         try:
#             guess = int(input("请输入你猜的数字: "))
#             attempts += 1
#             if guess < target_number:
#                 print("大一点！")
#             elif guess > target_number:
#                 print("小一点！")
#             else:
#                 print("恭喜你猜对了！🎉")
#                 print(f"你用了 {attempts} 次猜中了数字 {target_number}")
#                 break
#             if attempts >= max_attempts:
#                 print("💡 智商余额明显不足，游戏结束！")
#                 print(f"正确答案是: {target_number}")
#                 break
#             else:
#                 print(f"你还剩 {max_attempts - attempts} 次机会")
#         except ValueError:
#             print("请输入有效的整数！")
# if __name__ == "__main__":
#     guess_number_game()
# 1、求100以内的所有质数
# 2、求1000以内的水仙花数
# 3、假设有n个台阶，每跨一步只能上1阶或者2阶台阶。求总共有多少种走法
# n=int(input("请输入一个正数"))
# for i in range(1,n):
#     for j in range(1,n-1):
#         if n<=3:
#             print("{n}以内没有质数")
#         else:
#             if i % j==0:
#                 print("%d",(i))
#                 break
# class Teacher:
#     def __init__(self) -> None:
#         self.name=None
#         self.age=None
#         self.number=None
#         self.subject=None
#     def teach(self):
#         print(f'{self.name}正在教授{self.subject}')
# class Student:
#     def __init__(self)->None:
#         self.name=None
#         self.age=None
#         self.number=None
#         self.class_num=None
#     def study(self):
#         print(f'{self.name}正在学习{self.class_num}')
# t1 = Teacher()
# t1.name = '张三'
# t1.age = 30
# t1.number = '001'
# t1.subject = '数学'
# t1.teach()
# s1 = Student()
# s1.name = '李四'
# s1.age = 18
# s1.number = '002'
# s1.class_num = '1班'
# s1.study()
#li=[1,2,……,34]
# all_red_balls=[x for x in range(1,34)]
# all_blu_balls=[x for x in range(1,17)]
# import numpy as np
# import pandas as pd
# import matplotlib.pyplot as plt
# plt.rcParams['font.sans-serif'].insert(0,'SimHei')
# plt.rcParams['axes.unicode_minus'] = False
# df3 = pd.read_csv(
#     '2023年北京积分落户数据.csv',
#     # encoding='utf-8',   # 字符集
#     # sep='\t',           # 字段的分隔符（默认是逗号）
#     # index_col='公示编号', # 指定充当行索引的列
#     # usecols=['公示编号','姓名','积分分值'], # 指定需要加载的列
#     # nrows=10,           # 指定加载多少行
#     # skiprows=np.arange(1, 21), # 跳过哪些行
#     # true_values=['是','Y','Yes','yes'],  # 哪些值视为布尔值True
#     # false_values=['否','N','No','no'],   # 哪些值视为布尔值False
#     # na_values=["---",'N/A'], # 哪些值视为空值
# )
# df3.info()
# print(df3.head(3))
# print(df3.tail(3))
#从Excel文件中加载数据创建DataFrame
#从Excel文件中加载数据创建DataFrame
# df4 = pd.read_excel(
#     '2022年股票数据.xlsx',
#     sheet_name='JD',#加载的工作表的名字'
#     usecols=['Date','Open','Close'],
#     index_col='Date'
# )
# print(df4.head())
# import pandas as pd
# #创建一个Series对象，指定名称为'A'，值分别为1，2，3，4
# #默认索引为0，1，2，3
# series=pd.Series([1,2,3,4],name='A')
# #显示Series对象
# print(series)
# #如果你想要显式地设置索引，可以这样做：
# custom_index=[1,2,3,4] #自定义索引
# series_with_index=pd.Series([1,2,3,4],index=custom_index,name='A')
# #显示带有自定义索引的series对象
# print(series_with_index)
import pandas as pd
#创建一个简单的DataFrame
# import pandas as pd
#
# df4 = pd.read_excel(
#     '2022年股票数据.xlsx',
#     engine='openpyxl',  # 明确告诉pandas使用openpyxl
#     sheet_name='JD',
#     usecols=['Date','Open','Close'],
#     index_col='Date'
# )
# print(df4.head())
# import pandas as pd
# df = pd.read_csv('property-data.csv')
# print(df['NUM_BEDROOMS'])
# print(df['NUM_BEDROOMS'].isnull())
# import pandas as pd
# df =pd.read_csv('property-data.csv')
# new_df = df.dropna()
# print(new_df.to_string())

# import pandas as pd
# df =pd.read_csv('property-data.csv')
# df.dropna(subset=['PID','ST_NUM'],inplace = True)
# print(df.to_string())

# import pandas as pd
# df = pd.read_csv('property-data.csv')
# df.fillna(12345433454,inplace=True)
# print(df.to_string())

# import pandas as pd
# df = pd.read_csv('property-data.csv')
# # df['PID'].fillna(1234543,inplace=True)
# df.fillna({'PID':'1234543'},inplace=True)
# print(df.to_string())

# import pandas as pd
# df = pd.read_csv('property-data.csv')
# x = df["ST_NUM"].mean()
# df["ST_NUM"].fillna(x,inplace=True)
# print(df.to_string())
# #也可用mean(),mode(众数)，median

# import pandas as pd
# person = {
#     "name": ['Google', 'Ru', 'Taobao','han'],
#     "age": [50, 200, 12345,92]
# }
# df = pd.DataFrame(person)
# for x in df.index:
#     if df.loc[x, "age"] > 120:
#         df.loc[x, "age"] = 120
# print(df.to_string())
#drop能删掉，df.drop



